package io.xiaojl.xj2ee.task.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import io.xiaojl.xj2ee.task.entity.ScheduleJobLogEntity;
import io.xiaojl.xj2ee.task.mapper.ScheduleJobLogEntityMapper;
import io.xiaojl.xj2ee.task.service.ScheduleJobLogService;
import io.xiaojl.xj2ee.task.utils.PageWrapper;

@Service("scheduleJobLogService")
public class ScheduleJobLogServiceImpl implements ScheduleJobLogService {
	@Autowired
	private ScheduleJobLogEntityMapper baseMapper;
	@Override
	public PageWrapper<ScheduleJobLogEntity> queryPage(Map<String, Object> params) {
		PageWrapper<ScheduleJobLogEntity> pageWrapper = new PageWrapper<>(params);
		PageHelper.startPage(pageWrapper.getCurrPage(), pageWrapper.getPageSize(), pageWrapper.getOrderBy());
		
		List<ScheduleJobLogEntity> list = baseMapper.selectListByPage(pageWrapper.getCondition());
		PageInfo<ScheduleJobLogEntity> page = new PageInfo<>(list);
		
		pageWrapper.setList(page.getList());
		pageWrapper.setTotalCount(Integer.parseInt(page.getTotal()+""));
		pageWrapper.setTotalPage(page.getPages());
        return pageWrapper;
	}
	
	@Override
	public int insert(ScheduleJobLogEntity record) {
		return baseMapper.insertSelective(record);
	}

	@Override
	public ScheduleJobLogEntity selectById(Long logId) {
		return baseMapper.selectByPrimaryKey(logId);
	}

}
